package com.right.health.app.ui.registered.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.magic.basic.adapter.BaseAbsAdapter;
import com.magic.basic.utils.TimeUtil;
import com.right.health.app.R;
import com.right.health.app.bean.HomeItem;
import com.right.health.app.bean.PayClinicBean;

public class PayClinicAdapter extends BaseAbsAdapter<PayClinicBean>{
    public PayClinicAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_pay_clinic, null);
            viewHolder.timeTv = convertView.findViewById(R.id.tv_time);
            viewHolder.titleTv = convertView.findViewById(R.id.tv_title);
            viewHolder.costTv = convertView.findViewById(R.id.tv_cost);
            viewHolder.typeTv = convertView.findViewById(R.id.tv_pay_type);
            convertView.setTag(viewHolder);

        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        PayClinicBean bean = mDataSource.get(position);
        viewHolder.titleTv.setText(bean.getDeptname()+"  "+bean.getDoctorname());
        viewHolder.timeTv.setText("就诊时间: "+ TimeUtil.convertTime(TimeUtil.TIME_FORMAT,bean.getTime()));
        viewHolder.costTv.setText("￥"+bean.getPayamout());
        if (!TextUtils.isEmpty(bean.getSettletype())) {
            viewHolder.typeTv.setText("(" + bean.getSettletype() + ")");
        }
        return convertView;
    }

    public static class ViewHolder{
       public TextView titleTv,timeTv,costTv,typeTv;
    }
}
